<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>

<html>
<head>
	<c:import url="css.jsp"></c:import>    
</head>
<body>
<c:import url="header.jsp"></c:import>

	<div id="content">

<c:if test="${ fn:contains(requestScope['javax.servlet.forward.servlet_path'] , 'add')  }">
	<form action="addItem.do" method="post" >
		${error } </br>
		${result}<br/>
		ISBN : <input name="isbn" /> </br>
		<input type="submit" value="add" />
	</form>
</c:if>

<c:if test="${ fn:contains(requestScope['javax.servlet.forward.servlet_path'] , 'remove')  }">
	${result}
	<c:forEach items="${ items}" var="item">
		${ item.itemId } - ${ item.isbn }  <a href="removeItem.do?id=${item.itemId}"> remove </a> </br>
		
	</c:forEach>
</c:if>
<c:if test="${ fn:contains(requestScope['javax.servlet.forward.servlet_path'] , 'update')  }">
	${result}
	<c:forEach items="${ items}" var="item">
		${ item.itemId } - ${ item.isbn }  <a href="#" onclick="document.getElementById('${item.itemId}').style.display='block'"> update </a> </br>
	
	
		<div id="${item.itemId}" style="display:none">
			<form action="updateItem.do" method="post" >
				${error } </br>
				${result}<br/>
				 <input type="hidden" name="id" value="${item.itemId }" />
				Id : <input value="${item.itemId }" disabled="disabled" /> </br>
				ISBN:  <input name="isbn" value="${item.isbn }" /> <br/>
				<input type="submit" value="update" />
			</form>
		</div>
	</c:forEach>
</c:if>

<c:if test="${ fn:contains(requestScope['javax.servlet.forward.servlet_path'] , 'show')  }">
	${result}
<div id="title">The available items are :</div>
	<table class="gridtable">
			<thead>
				<tr>
					<th scope="col">Item ID</th>
					<th scope="col">ISBN</th>
					<th scope="col">Available</th>
				</tr>
			</thead>
			<tbody>
			<c:forEach items="${ items}" var="item">
			<tr>
			<td>${ item.itemId }</td>
			<td>${ item.isbn }</td>
			<td><a href="borrowItem.do?id=${item.itemId}">Borrow it now!</a></td> <tr>
		 
				

			</c:forEach>
			</tbody>
	</c:if>
</div>


	
</body>
</html>